{{template "base"}}
{{define "body"}}
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">输入框</label>
            <div class="layui-input-block">
                <input type="text" name="username" required lay-verify="required" placeholder="请输入账号" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码框</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">输入框</label>
            <div class="layui-input-block">
                <input type="text" name="captcha" required lay-verify="required" placeholder="请输入验证码" autocomplete="off"
                       class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <label>
                    <img src="/exec?f=COMO0002">
                </label>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
{{end}}
{{define "footer"}}
    <script>
        //Demo
        layui.use('form', function () {
            var form = layui.form;
            var $ = layui.jquery;
            //监听提交
            form.on('submit(submit)', function (data) {
                $.ajax({
                    url: "/api/login",
                    type: 'POST',
                    data: JSON.stringify(data.field),
                    contentType: "application/json",
                    success: function (res) {
                    },
                    error: function (result) {
                    }
                });
                return false;
            });
        });
    </script>
{{end}}